﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint;

namespace Sogeti.DynamicCustomAction
{
    class ManageSubWebs : WebControl
    {
        protected override void OnLoad(EventArgs e)
        {
            EnsureChildControls();
            base.OnLoad(e);
        }

        protected override void CreateChildControls()
        {
            MenuItemTemplate menu = new MenuItemTemplate();
            menu.Text = "This site has " + SPContext.Current.Web.GetSubwebsForCurrentUser().Count.ToString() + " sub sites";
            menu.Description = "Click here to manage subsites";
            menu.ClientOnClickNavigateUrl = SPContext.Current.Web.Url + "/_layouts/mngsubwebs.aspx";
            Controls.Add(menu);
        }
    }
}
